import { Store } from "vuex";
import type { RootState } from "@/store/types";
import { computed, ref } from "vue";
import type { App, Directive } from "vue";

//当传入值不在store中时隐藏dom元素
function install(app: App, store: Store<RootState>) {
  
  const instance: Directive = {
    mounted(el, binding, vnode) {
      const {value}=binding
      if(value){
        let permission=false
        for(let i in value){
            permission=store.state.auth.permi.includes(value[i]) || permission
        }
        if(!permission){
            el.parentNode && el.parentNode.removeChild(el)
        }
      }else{
        throw new Error('请设置内容')
      }
    },
  };
  app.directive("tableColumnShow", instance);
}

export default install;
